package com.gqj.meter.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gqj.common.annotation.Log;
import com.gqj.common.core.controller.BaseController;
import com.gqj.common.core.domain.AjaxResult;
import com.gqj.common.enums.BusinessType;
import com.gqj.meter.domain.MdStoreLocChg;
import com.gqj.meter.service.IMdStoreLocChgService;
import com.gqj.common.utils.poi.ExcelUtil;
import com.gqj.common.core.page.TableDataInfo;

/**
 * 储位变更记录Controller
 *
 * @author lxq
 * @date lxq-02-10
 */
@RestController
@RequestMapping("/meter/mdStoreLocChg")
public class MdStoreLocChgController extends BaseController
{
    @Autowired
    private IMdStoreLocChgService mdStoreLocChgService;

    /**
     * 查询储位变更记录列表
     */
    @PreAuthorize("@ss.hasPermi('meter:mdStoreLocChg:list')")
    @GetMapping("/list")
    public TableDataInfo list(MdStoreLocChg mdStoreLocChg)
    {
        startPage();
        List<MdStoreLocChg> list = mdStoreLocChgService.selectMdStoreLocChgList(mdStoreLocChg);
        return getDataTable(list);
    }

    /**
     * 导出储位变更记录列表
     */
    @PreAuthorize("@ss.hasPermi('meter:mdStoreLocChg:export')")
    @Log(title = "储位变更记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MdStoreLocChg mdStoreLocChg)
    {
        List<MdStoreLocChg> list = mdStoreLocChgService.selectMdStoreLocChgList(mdStoreLocChg);
        ExcelUtil<MdStoreLocChg> util = new ExcelUtil<MdStoreLocChg>(MdStoreLocChg.class);
        util.exportExcel(response, list, "储位变更记录数据");
    }

    /**
     * 获取储位变更记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('meter:mdStoreLocChg:query')")
    @GetMapping(value = "/{chgId}")
    public AjaxResult getInfo(@PathVariable("chgId") Long chgId)
    {
        return success(mdStoreLocChgService.selectMdStoreLocChgByChgId(chgId));
    }

    /**
     * 新增储位变更记录
     */
    @PreAuthorize("@ss.hasPermi('meter:mdStoreLocChg:add')")
    @Log(title = "储位变更记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MdStoreLocChg mdStoreLocChg)
    {
        return toAjax(mdStoreLocChgService.insertMdStoreLocChg(mdStoreLocChg));
    }

    /**
     * 修改储位变更记录
     */
    @PreAuthorize("@ss.hasPermi('meter:mdStoreLocChg:edit')")
    @Log(title = "储位变更记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MdStoreLocChg mdStoreLocChg)
    {
        return toAjax(mdStoreLocChgService.updateMdStoreLocChg(mdStoreLocChg));
    }

    /**
     * 删除储位变更记录
     */
    @PreAuthorize("@ss.hasPermi('meter:mdStoreLocChg:remove')")
    @Log(title = "储位变更记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{chgIds}")
    public AjaxResult remove(@PathVariable Long[] chgIds)
    {
        return toAjax(mdStoreLocChgService.deleteMdStoreLocChgByChgIds(chgIds));
    }
}
